/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SysAguas.modelo;

import java.util.Date;
import java.util.Calendar;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;


/**
 *
 * @author Heitor
 */
public class Teste {

    public static void main(String[] args) {

        EntityManagerFactory fabrica = Persistence.createEntityManagerFactory("SysAguasBetaPU");
        EntityManager em = fabrica.createEntityManager();

       em.getTransaction().begin();

        /*TipoQuarto tipoQuarto = TipoQuarto.SOLTEIRO_LUXO;
        Quarto q = new Quarto();
        q = em.find(Quarto.class, 1);
        System.out.println(q.getNome());
        System.out.println(q.getTipoQuarto());*/



   /*     reserva.setStatusReserva(StatusReserva.RESERVADA);
        reserva.setDataModificacao(Calendar.getInstance().getTime());
        reserva.setDataChegada(null);
        reserva.setDesconto(10);
        Date date = new Date();
        date =  Calendar.getInstance().getTime();
        date.setDate(30);
        reserva.setDataChegada(date);*/

        /*Date saida = new Date();
        saida = Calendar.getInstance().getTime();
        saida.setDate(05);
        saida.setMonth(6);*/
  /************************************************************************
 /*       Integer ab = 1;
        String query1 = "SELECT r FROM Reserva AS r where r.idReserva = ?1";

        Query consulta = em.createQuery("SELECT r FROM Reserva AS r where r.id = ?1");
        consulta.setParameter(1,ab);
        Reserva reserva = new Reserva();

        reserva = (Reserva) consulta.getSingleResult();

     

         Date saida = new Date(2010, 06, 05);
        reserva.setDataSaida(saida);
     System.out.println(reserva.getDataSaida());
        System.out.println(saida);*/
      /*******************************************************************/
      //  reserva.setQuarto(q);
       // q.setReservaQ(reserva);



        /*q.setNumeroQuarto(1);
        q.setNome("Prinsesa Isabel");
        q.setDescricao("Decoracao portuguesa");
        q.setCapacidade(3);
        q.setValorDiaria(65);
        q.setTipoQuarto(tipoQuarto);

        //  System.out.println(q.getTipoQuarto());
        em.persist(q);*/
    //   Hospede a = new Hospede();
        /*Hospede hop = new Hospede();
        hop.setNome("Diego");
        hop.setSobrenome("Ribeiro");

        Telefone t = new Telefone("03731", "99898989");
        hop.setTelefones(t);
        t.setHospede(hop);

        Telefone tt = new Telefone("03131", "97942271");
        hop.setTelefones(tt);
        tt.setHospede(hop);

        em.persist(hop);*/
  //    a = em.find(Hospede.class, 4);

//       System.out.println(a.getNome());
    //  Date aa = new Date() ;
/*
        a.setDataModificacao(Calendar.getInstance().getTime());
*/
        Endereco en =new Endereco();
        en.setRua("Rua Sao Paulo,1300");
        en.setBairro("Centro");
        en.setCep("35525-000");
        en.setCidade("Caxambu");
        en.setPais("Brasil");
        
        en.setEstado("Minas Gerais");
/*
        en.setHospede(a);

        a.setEnderecoH(en);

        for (int i = 0; i < a.getTelefones().size(); i++) {

            System.out.println(a.getTelefones().get(i).getNumero());
            System.out.println(a.getTelefones().get(i).getHospede().getNome());
*/
  /*
     Date date = new Date(110,06,05);
        System.out.println(date);

        Cheque cheque = new Cheque();
      /*  cheque.setDinheiro(false);
        cheque.setBanco("4567-1");
        cheque.setBanco("Banco do Brasil");
        long aaaa= 1111111111;
        cheque.setNumero(aaaa);
        cheque.setConta("365895-5");
  
        cheque.setValorPago(845.25);
        cheque.setValorTotal(412.25);

        Reserva reserva = new Reserva();
        
        reserva = em.find(Reserva.class, 2);

        System.out.println(reserva.getStatusReserva());
*/
  //   reserva.setPagamentoR(cheque);
/*
        cheque = em.find(Cheque.class, 5);
     cheque.setAgencia("451254-1");

*/
       Reserva reserva1 = new Reserva();
       Reserva reserva2 = new Reserva();
  //     Hospede hospede = new Hospede();

    //   hospede = em.find(Hospede.class, 4);
       reserva1 = em.find(Reserva.class, 1);
       reserva2 = em.find(Reserva.class, 2);

 //      hospede.addReserva(reserva1);
 //      hospede.addReserva(reserva2);

 //      reserva1.setHospedeR(hospede);
  //     reserva2.setHospedeR(hospede);
       Telefone tel = new Telefone();
       tel.setDdd("03131");
       tel.setNumero("357334108");



       Pousada p = new Pousada();
        p.setNome("SYSAGUAS");
        p.addReserva(reserva2);
        p.addReserva(reserva1);


        p.setEndereco(en);
        en.setPousadaE(p);

        p.addTelefone(tel);
        tel.setPousadaT(p);

        reserva1.setPousadaR(p);
        reserva2.setPousadaR(p);


  //      em.persist();
        em.flush();
        em.getTransaction().commit();
        em.close();

    }
}
